<template>
    <div>
        <el-row :gutter="20">
            <template v-if="panels.length == 0">
                <el-col :span="6" v-for="i in panels.length" :key="i">
                    <el-skeleton style="width: 100%" animated loading>
                        <template #template>
                            <el-card shadow="hover" class="border-0">
                                <template #header>
                                    <div class="flex justify-between">
                                        <el-skeleton-item variant="text" style="width: 50%" />
                                        <el-skeleton-item variant="text" style="width: 10%" />
                                    </div>
                                </template>
                                <el-skeleton-item variant="text" style="width: 85%" />
                                <el-divider />
                                <div class="flex justify-between">
                                    <el-skeleton-item variant="text" style="width: 50%" />
                                    <el-skeleton-item variant="text" style="width: 10%" />
                                </div>
                            </el-card>
                        </template>
                    </el-skeleton>
                </el-col>
            </template>
            <el-col :span="6" :offset="0" v-for="(item, index) in panels" :key="index">
                <el-card shadow="hover" class="border-0">
                    <template #header>
                        <div class="flex justify-between">
                            <span>{{ item.title }}</span>
                            <el-tag :type="item.unitColor" effect="plain">
                                {{ item.unit }}
                            </el-tag>
                        </div>
                    </template>
                    <span class="font-bold text-green-500" style="font-size: 30px;">
                        {{ item.value }}
                    </span>
                    <el-divider />
                    <div class="flex justify-between">
                        <span>{{ item.subTitle }}</span>
                        <span>{{ item.subValue }}</span>
                    </div>
                </el-card>
            </el-col>
        </el-row>
        <indexNavs />
        <el-row :gutter="20" class="mt-5">
            <el-col :span="12" :offset="0">
                <IndexCharts v-permission="['getStatistics3,GET']"/>
            </el-col>
            <el-col :span="12" :offset="0">
                <IndexCard title="店铺及商品提示" tip="店铺及商品提示" :btns="goods"/>
                <IndexCard style="margin-top: 20px;" title="交易提示" tip="需要立即处理的交易订单" :btns="order"/>
            </el-col>
        </el-row>

        <el-row :gutter="20" class="mt-5">
            <el-col :span="12" :offset="0">
                <IndexCard title="店铺及商品提示" tip="店铺及商品提示" :btns="goods"/>
                <IndexCard style="margin-top: 20px;" title="交易提示" tip="需要立即处理的交易订单" :btns="order"/>
            </el-col>
            <el-col :span="12" :offset="0">
                <IndexZheXian/>
            </el-col>
        </el-row>

        


    </div>
</template>

<script setup>
import { reactive, ref } from 'vue'
import { useRouter } from "vue-router";

import { showModal, success } from '~/composables/util'
import indexNavs from '~/components/indexNavs.vue'
import IndexCharts from '~/components/IndexCharts.vue'
import IndexZheXian from '~/components/IndexZheXian.vue'

import IndexCard from '~/components/IndexCard.vue'



import { useStore } from 'vuex'

import { statistics1,statistics2 } from '~/api/index'

const router = useRouter()
const store = useStore()

const panels = ref([])
const goods = ref([])
const order = ref([])


init()
function init() {

    statistics1().then(res => {
        panels.value = res.panels
    })

    statistics2().then(res => {
        goods.value = res.goods
        order.value = res.order

    })
}
</script>